<template>
	<view class="down_wrap">
		<centHead :headName='headName'></centHead>
		<view class="u-font-32 u-p-26 u-p-r-30 u-p-l-30 title">
			助业员工端APP下载：
		</view>
		<view class="down__Owner_App ">
			<view class="down_cont_btn">
				<u-button @click='downBtn(2)' shape="circle" type="warning">下载APP</u-button>
			</view>
		</view>
		<view class="u-font-32 u-p-26 u-p-r-30 u-p-l-30 title">
			助业APP下载：
		</view>
		<view class="down_App u-m-b-50">
			<view class="down_cont_btn">
				<u-button @click='downBtn(1)' shape="circle" type="warning">下载APP</u-button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				headName: 'APP下载'
			}
		},
		methods: {
			downBtn(val) {

				if (val == 1) {

					// #ifdef APP-PLUS
					var name = "uni.UNI21DD88C"; //助业网 app
					let appurl = "market://details?id=" + name;
					plus.runtime.openURL(appurl); //该代码仅在app中生效
					// #endif
					// #ifdef H5
					uni.request({
						url: 'https://admin.515f.com/api/rest/v1/venusSysAppUpgradeService/getNewAppInfoByType',
						method: 'POST',
						data: {
							app_type: 0
						},
						success: res => {
							this.info = res.data.data;
							window.location.href = this.info.wgt_link;
							// location.href = this.info.android_link;
						}
					})
					//该代码仅在h5中生效
					// #endif
				} else if (val == 2) {

					// #ifdef APP-PLUS
					var name = "uni.UNI531402B"; //员工端 app
					let appurl = "market://details?id=" + name;
					plus.runtime.openURL(appurl);
					// #endif
					// #ifdef H5
					uni.request({
						url: 'https://admin.515f.com/api/rest/v1/venusSysAppUpgradeService/getNewAppInfoByType',
						method: 'POST',
						data: {
							app_type: 1
						},
						success: res => {
							this.info = res.data.data;
							window.location.href = this.info.wgt_link;
							// location.href = this.info.android_link;
						}
					})
					// #endif
				}
				//	=== 添加下载记录
				//   `app_type` varchar(255) DEFAULT NULL COMMENT 'app类型:1.助业app 2.员工app 3.业主app',
				this.$request.api.appDownloads({
					org_id: uni.getStorageSync('projectItem').orgId,
					user_id: uni.getStorageSync('rawData').userId,
					user_roles: 1, //前端默认为1 代表用户 如果 user_id 为空为游客
					app_type: val
				}).then(res => {

				})


			}
		}
	}
</script>

<style lang="scss">
	.down_wrap {
		width: 100vw;
		height: 100vh;
		background: #f6f6f6;
		overflow: hidden;

		.title {
			font-size: 18px;
			font-weight: bold;
		}

		.down_pro {
			width: 750rpx;
			height: 422rpx;
			// background: url(../../static/image/proImage2.png)center no-repeat;
			background-size: 100%;
			position: relative;
		}

		.down_App {
			width: 700rpx;
			margin-left: 26rpx;
			height: 390rpx;
			background: url(https://clhy-img.oss-cn-beijing.aliyuncs.com/ownerImage/zhuYeApp1.png);
			background-size: 100%;
			position: relative;
			border-radius: 8px;
		}

		.down__Owner_App {
			width: 700rpx;
			margin-left: 26rpx;
			height: 390rpx;
			background: url(https://clhy-img.oss-cn-beijing.aliyuncs.com/ownerImage/proImage.png);
			background-size: 100%;
			border-radius: 8px;
			position: relative;
		}

		.down_cont_btn {
			position: absolute;
			width: 180rpx;
			height: 60rpx;
			top: 245rpx;
			left: 40rpx;

			.u-btn {
				width: 100%;
				height: 100%;
			}
		}
	}
</style>